{% extends "tj3/tj3.html" %}

{% block navigation %}
	<script type="text/javascript">
		$('document').ready(function(){
			$("#my_tabs").tabs();
		});
	</script>
{% endblock navigation %}

{% block content  %} 

<h1 class="ui-widget ui-widget-header">{{task.project.name}}/{{task.name}}</h1>

<table>
<tbody>
<tr><td>Task<td>{{task.name}}</tr>
<tr><td>Description<td>{{task.description}}</tr>
<tr><td>Created<td>{{task.created}}</tr>
</tbody>
</table>


<div id="my_tabs">
<form action="." method="post" enctype="multipart/form-data">
	<ul>
		<li><a href="#period">Duration & Effort</a></li>
		<li><a href="#resource">Resource Assignment</a></li>
		<li><a href="#budget">Budget & Cost</a></li>
		<li><a href="#dependency">Dependency</a></li>
		<li><a href="#journal">Journals</a></li>		
	</ul>
	
	
	<div id="period" class="mycontent">		
	<p>Task periods are defintions of timings. In the baseline scenario, you 
	specify a wish list of when the task should start/end, or how long it should last,
	or if you'd like to think in term of man power, how many people you would need.
	Further, you tell the system any constraints it should observer &mdash; what is the maximum
	deadline the task should not pass, and the like.
	<br>
	<br>

		<h2 class="ui-state-highlight ui-corner-all">Projections ({{updated_on}})
		</h2>
			<div>
			<table>
				<tr><td>
					{% for s in status %}<td>{{s.scenario|capfirst}}{%endfor%}
				<tr><td>Start Date:
					{% for s in status %}<td>{{s.start}}{%endfor%}
				<tr><td>End Date:
					{% for s in status %}<td>{{s.end}}{%endfor%}
				<tr><td>Duration:
					{% for s in status %}<td>{{s.duration}}{%endfor%}
				<tr><td>Effort:
					{% for s in status %}<td>{{s.effort}}{%endfor%}
				<tr><td>Completion:
					{% for s in status %}<td>{{s.completion}}%{%endfor%}
			</table>
			</div>
			
		<h2 class="ui-state-highlight ui-corner-all">Set Start Date and End Date
		<span class="float_right">
			<a href={% url period_create task.id%}><span class="ui-icon ui-icon-plusthick" title="Create a new period"></span></a>
		</span>
		</h2>
			<div>
			<table>
				<tr><td>
					{% for p in periods %}<td>
						<a href="{% url period_edit p.id,1 %}">
							{{p.scenario|capfirst}}
							<span class="ui-icon ui-icon-wrench"></span>
						</a>
					{%endfor%}
				<tr><td>Start Date:
					{% for p in periods %}<td>{{p.start}}{%endfor%}
				<tr><td>End Date:
					{% for p in periods %}<td>{{p.end}}{%endfor%}
			</table>
			</div>
			
		<h2 class="ui-state-highlight ui-corner-all">Set the Task Type
		<span class="float_right">
			<a href={% url period_create task.id%}><span class="ui-icon ui-icon-plusthick" title="Create a new period"></span></a>
		</span>
		</h2>		
			<div>
			<table>
				<tr><td>
					{% for p in periods %}<td>
						<a href={% url period_edit p.id,2 %}>{{p.scenario|capfirst}}
						</a>
						<span class="ui-icon ui-icon-wrench"></span>
					{%endfor%}
				<tr><td>Length:
					{% for p in periods %}<td>{{p.length}}{%endfor%}
				<tr><td>Duration:
					{% for p in periods %}<td>{{p.duration}}{%endfor%}
				<tr><td>Effort:
					{% for p in periods %}<td>{{p.effort}}{%endfor%}
			</table>
			</div>		
		
		<h2 class="ui-state-highlight ui-corner-all">Set Date Constraints
		<span class="float_right">
			<a href={% url period_create task.id %}><span class="ui-icon ui-icon-plusthick" title="Create a new period"></span></a>
		</span>
		</h2>		
			<div>
			<table>
				<tr><td>
					{% for p in periods %}<td>
						<a href={% url period_edit p.id,3 %}>{{p.scenario|capfirst}}
						</a>
						<span class="ui-icon ui-icon-wrench"></span>
					{%endfor%}
				<tr><td>Min Start:
					{% for p in periods %}<td>{{p.min_start}}{%endfor%}
					<td>
				<tr><td>Max Start:
					{% for p in periods %}<td>{{p.max_start}}{%endfor%}
					<td>
				<tr><td>Min End:
					{% for p in periods %}<td>{{p.min_end}}{%endfor%}
					<td>
				<tr><td>Max End:
					{% for p in periods %}<td>{{p.max_end}}{%endfor%}
					<td>
			</table>
			</div>
	</div>
	
	<div id="resource" class="mycontent">			
	<p>Resource assignment is essential if the Duration & Period has been determined to
	be effort based. The effort value would be the amount of work, where the resource
	assignment would determine who can be allocated to do the work. Each resource bears a work limit
	which further specifies the availability of time that the resource can work on this task. The scheduler
	will take these information to level resource and calculate task durations.
	
	<br>
	<br>

		<h2 class="ui-state-highlight ui-corner-all">Set Resource Assignments
		<span class="float_right">
			<a href={% url resource_allocate task.id%} class="ui-icon ui-icon-plusthick" title="Assign resources"></a>
		</span>
		</h2>
			
		{% for r,editable in resource_assigned %}
		<div class="primary_resource">
			<span class="ui-icon ui-icon-person"></span>
			{{r.primary.first_name|capfirst}} {{r.primary.last_name|capfirst}}
			{% if editable %}
				<span class="ui-icon ui-icon-grip-dotted-vertical" style="float: left; margin-right: .3em;"></span>
					<a href="{% url resource_allocate_remove task.id,r.id %}" class="ui-icon ui-icon-trash float_right" title="Remove this resource from the task"></a>
					<a href="{% url worklimit_edit r.primary.work_limit.id %}" class="ui-icon ui-icon-carat-2-n-s float_right" title="Edit worklimit"></a>
					<a href="{% url timeoff_create r.primary.id %}" class="ui-icon ui-icon-scissors float_right" title="Take time off"></a>
					<a href="{% url resource_edit r.primary.id %}" class="ui-icon ui-icon-wrench float_right" title="Edit resource"></a>
					<a href="{% url project_calendar task.project.id,task.id,r.primary.id %}" class="ui-icon ui-icon-document float_right" title="Create a new booking journal"></a>
			{% else %}
				<a href="{% url project_calendar task.project.id,task.id,r.primary.id %}" class="ui-icon ui-icon-document float_right" title="Create a new booking journal"></a>
				<span class="float_right fancy">inherited</span>
			{% endif %}
		</div>
			{% if r.alternative %}
				<div class="alternative_resource">
				<h3>Alternative: 
					<span class="ui-icon ui-icon-person"></span>
		
					{{r.alternative.first_name|capfirst}} {{r.alternative.last_name|capfirst}}
					</a>
				</h3>
				{% if editable %}
				<span class="ui-icon ui-icon-grip-dotted-vertical" style="float: left; margin-right: .3em;"></span>
					<a href="{% url worklimit_edit r.alternative.work_limit.id %}" class="float_right">worklimit</a>
					<a href="{% url timeoff_create r.alternative.id %}" class="float_right">timeoff</a>
					<a href="{% url resource_edit r.alternative.id %}" class="ui-icon ui-icon-wrench float_right" title="Edit resource"></a>
					<a href="{% url project_calendar task.project.id,task.id,r.alternative.id %}" class="ui-icon ui-icon-document float_right" title="Create a new booking journal"></a>
				{% else %}
					<a href="{% url project_calendar task.project.id,task.id,r.alternative.id %}" class="ui-icon ui-icon-document float_right" title="Create a new booking journal"></a>
					<span class="float_right fancy">inherited</span>
				{% endif %}
				</div>
			{% endif %}
		{% endfor %}
	</div>			

	<div id="budget" class="mycontent">
	<p>Task budgets are to track financial performance of a project. It is also the basis for
	performance the Earned Value Analysis. Budget and actual cost is a pair value that can be viewed
	in the same way as the planned task duration versus the actual duration. Therefore, a budget
	value attached to the baseline scenario, eg. Plan, would be the assigned budget to
	that task; and the budget value attached to the tracking scenarios are the actual costs.
	Further, each task can also has a "management reserve", which would be used in EVA to calculate Budget 
	At Completion (BAC).
	<br>
	<br>
	{% if not is_leaf %}
	<blockquote>
		This task is a container task. You should not assign a budget to a container task. Its values will be 
	calculated by summing up its children tasks.
	</blockquote>
	{% endif %}
	
		<div>
			{% if is_leaf %}
			<h2 class="ui-state-highlight ui-corner-all">Set Budgets and Costs
			<span class="float_right">
				<a href={% url budget_create task.id %}><span class="ui-icon ui-icon-plusthick" title="Create a new budget"></span></a>
			</span>
			</h2>

				<table>
					<tbody>
						<tr><td>
							{% for b in budgets %}<td>
								<a href={% url budget_edit b.id %}>{{b.scenario|capfirst}}
								</a>
								<span class="ui-icon ui-icon-wrench"></span>
							{%endfor%}
						<tr><td>Budget & Cost
							{% for b in budgets %}<td>{{b.budget}}{%endfor%}
						<tr><td>Management Reserve
							{% for b in budgets %}<td>{{b.reserve}}{%endfor%}
					</tbody>
				</table>
			{% endif %}
		</div>	
	</div>

	<div id="dependency" class="mycontent">		
	<p>Task dependency is a relationship between two tasks linked by a dependency between their 
	finish and start dates. Instead of giving the system a fxied start date or end date,
	using dependency would put dates of the two linked tasks relative to each other.
	<br />
	<br />
	
		{% if we_deps|length %}
		<div>
			<h2 class="ui-state-highlight ui-corner-all">I Depend On Them
			<span class="float_right">
				<a href={% url project_main_plan task.project.id %}><span class="ui-icon ui-icon-plusthick" title="Create a new dependency"></span></a>
			</span>
			</h2>
			{% for d in we_deps %}
				<span class="">{{d.type}}</span>
				<span class="">{{d.on_what}}</span> <i>of</i> 
				<span class=""><a href="{%url task_detail d.to_task.id %}">{{d.to_task.name}}</a></span>
				{% if d.gap_duration %}
					<span"> &mdash; {{d.gap_duration}} (e)</span>
				{% endif %}
				
				{% if d.gap_length %}			
					<span> &mdash; {{d.gap_length}}</span>
				{% endif %}
				
				<div class="float_right">
					<a href={% url dep_delete d.id %} class="float_right ui-icon ui-icon-trash" title="Delete Dependency"></a>
					<a href={% url dep_edit d.id %} class="float_right ui-icon ui-icon-wrench" title="Edit Dependency"></a>
				</div>
				<br />
			{% endfor %}
		</div>
		{% endif %}
		<br />
		{% if they_deps|length %}
		<div>
			<h2 class="ui-state-highlight ui-corner-all">They Depend On Me
			</h2>
			{% for d in they_deps %}
				<i>
				<span class=""><a href="{%url task_detail d.from_task.id %}">{{d.from_task.name}}</a></span>
				<span class="">{{d.type}}</span>
				<span class="">{{d.on_what}}</span> <i>of Me</i> 
				{% if d.gap_duration %}
					<span"> &mdash; {{d.gap_duration}} (e)</span>
				{% endif %}
				
				{% if d.gap_length %}			
					<span> &mdash; {{d.gap_length}}</span>
				{% endif %}
				</i>
				<br />
			{% endfor %}
		</div>
		{% endif %}
	</div>
	
	<div id="journal" class="mycontent">
		{% for booking, j_list in journals %}
			<h3 class="ui-state-highlight ui-corner-all">{{ booking }}</h3>
				{% for jj in j_list %}
				{% for j in jj %}
					<span class="ui-icon ui-icon-comment" style="float: left; margin-right: .3em;"></span>
					{{j.booking.resource.first_name|capfirst}} {{j.booking.resource.last_name|capfirst}} 
					worked for {{j.booking.length}}:
						<div class="prefix-1">
						{% if j.alert == "green" %}
							<div class="ui-state-normal">{{j.summary}}
							</div>
						{% endif %}
						{% if j.alert == "yellow" %}
							<div class="ui-state-warning">{{j.summary}}
							</div>
						{% endif %}
						{% if j.alert == "red" %}
							<div class="ui-state-error">{{j.summary}}
							</div>
						{% endif %}
					
						<div class="fancy">
							{{j.description}}
						</div>
					</div>
				{% endfor %}
				{% endfor %}
				<br />
				
		{%endfor%}
	</div>	
</form>	
</div>

<br />

<h1 class="ui-state-highlight ui-corner-all">Go To</h1>
<div>
	<ul>
		<li><a href="{% url project_main_plan task.project.id %}">Project Planning</a>
	</ul>
</div>
{% endblock content %}
